<?php

header("content-type:text/html;charset=utf-8");
del_data();
function del_data()
{
    if (!isset($_GET['id'])) {
        exit("参数错误");
    }
    if (empty($_GET['id'])) {
        exit("用户ID不能为空");
    }
    $id = $_GET['id'];

    $conn = mysqli_connect("localhost", "root", "root", "test");
    if (!$conn) {
        exit("数据库连接失败" . mysqli_error());
    }
    $sql = "select * from user WHERE id = $id";
    $result = mysqli_query($conn, $sql) or exit("<br/>ERROR:<b>" . mysqli_error() . "</b><br/>SQL:" . $sql);
    if(!mysqli_num_rows($result)){exit("参数错误");}
    $sql = "delete from user WHERE id=$id";
    mysqli_query($conn,$sql) or exit("ERROR:<br/>".mysqli_error());
    mysqli_close($conn);
    echo '数据删除成功，返回<a href="pagingData.php">pagingData.php</a>查看数据';
}


?>